import pandas as pd
import os


def Time():
    # 源文件目录字符串差异化部分
    filelist = ["DMYS",
                "DMYS-HF",
                "H500",
                "PLAM-HF",
                "PM25",
                "PM25_13"
                ]
    path = "C:/Users/24350/IdeaProjects/Meteorological_BigData/Statistic"
    outpath = "C:/Users/24350/IdeaProjects/Meteorological_BigData/output"  # 输出目录
    os.makedirs(outpath, exist_ok=True)  # 新建输出目录
    for file in filelist:
        df = pd.read_table(path + "/" + file + ".txt", sep="\t", header=0)
        df["time"] = pd.to_datetime(df[["year", "month", "day", "hour"]])
        df.to_csv(outpath + "/" + file + ".csv", mode="w+", header=True, index=False)


if __name__ == '__main__':
    Time()